from sqlalchemy import Column, String, JSON, ForeignKey
from sqlalchemy.dialects.postgresql import UUID, JSONB
from pgvector.sqlalchemy import Vector
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class Person(Base):
    __tablename__ = 'persons'
    id = Column(UUID(as_uuid=True), primary_key=True, server_default='gen_random_uuid()')
    name = Column(String(100), nullable=False)
    person_metadata = Column(JSONB)

class FaceEmbedding(Base):
    __tablename__ = 'face_embeddings'
    id = Column(UUID(as_uuid=True), primary_key=True, server_default='gen_random_uuid()')
    person_id = Column(UUID(as_uuid=True), ForeignKey('persons.id'))
    embedding = Column(Vector(128), nullable=False)
    image_path = Column(String(500))
    detection_metadata = Column(JSONB)